<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="物料分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="categoryCode">
              <j-dict-select-tag type="list" disabled  v-model="model.categoryCode" dictCode="erp_goods_category,name,code" placeholder="请选择物料分类" />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="物料状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">-->
<!--              <j-dict-select-tag type="list" v-model="model.status" dictCode="dict_item_status" placeholder="请选择物料状态" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
          <a-col :span="8" >
            <a-form-model-item label="物料编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialCode">
              <a-input v-model="model.materialCode" disabled  placeholder="请输入物料编号" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="物料名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialName">
              <a-input v-model="model.materialName" disabled  placeholder="请输入物料名称" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="仓库" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="warehouseId">
              <j-dict-select-tag type="list" disabled  v-model="model.warehouseId" dictCode="erp_warehouse,name,id" placeholder="请选择仓库" />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="客户物料编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerMaterialCode">-->
<!--              <a-input v-model="model.customerMaterialCode" placeholder="请输入客户物料编号" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
          <a-col :span="8" >
            <a-form-model-item label="规格型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="noneSpec">
              <a-input v-model="model.noneSpec" disabled  placeholder="请输入规格型号" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="主计量单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="meUnit">
              <j-dict-select-tag type="list" disabled  v-model="model.meUnit" dictCode="ji_unit" placeholder="请选择主计量单位" />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="月份" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="month">-->
<!--              <a-input v-model="model.month" placeholder="请输入月份" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="本期收到数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receivedQuantity">-->
<!--              <a-input-number v-model="model.receivedQuantity" placeholder="请输入本期收到数量" style="width: 100%" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="本期发出数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="issuedQuantity">-->
<!--              <a-input-number v-model="model.issuedQuantity" placeholder="请输入本期发出数量" style="width: 100%" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="期末余额数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="endingBalanceQuantity">-->
<!--              <a-input-number v-model="model.endingBalanceQuantity" placeholder="请输入期末余额数量" style="width: 100%" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="期初余额数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="openingBalanceQuantity">-->
<!--              <a-input-number v-model="model.openingBalanceQuantity" placeholder="请输入期初余额数量" style="width: 100%" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
          <a-col :span="8" >
            <a-form-model-item label="库存数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="quantity">
              <a-input-number v-model="model.quantity" disabled  placeholder="请输入库存数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="在库数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inStockQuantity">
              <a-input-number v-model="model.inStockQuantity" disabled  placeholder="请输入在库数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="质检中数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inStorageQuantity">
              <a-input-number v-model="model.inStorageQuantity" disabled  placeholder="请输入入库中数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="扣货数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frozenQuantity">
              <a-input-number v-model="model.frozenQuantity" disabled  placeholder="请输入冻结数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>

          <a-col :span="8" >
            <a-form-model-item label="可用数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="availableQuantity">
              <a-input-number v-model="model.availableQuantity" disabled  placeholder="请输入可用数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="占用数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="occupationQuantity">
              <a-input-number v-model="model.occupationQuantity" disabled  placeholder="请输入占用数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="辅助单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="auUnit">
              <j-dict-select-tag type="list" disabled  v-model="model.auUnit" dictCode="zl_unit" placeholder="请输入辅助单位" />
              <!--              <a-input v-model="model.auUnit" placeholder="请输入辅助单位" ></a-input>-->
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="辅助数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="auxiliaryQuantity">
              <a-input-number v-model="model.auxiliaryQuantity" disabled  placeholder="请输入辅助数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="备用字段一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spareOne">-->
<!--              <a-input v-model="model.spareOne" placeholder="请输入备用字段一" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="备用字段二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spareTwo">-->
<!--              <a-input v-model="model.spareTwo" placeholder="请输入备用字段二" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="备用字段三" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spareThree">-->
<!--              <a-input v-model="model.spareThree" placeholder="请输入备用字段三" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="备用字段四" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spareFour">-->
<!--              <a-input v-model="model.spareFour" placeholder="请输入备用字段四" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="备用字段五" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spareFive">-->
<!--              <a-input v-model="model.spareFive" placeholder="请输入备用字段五" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24" >-->
<!--            <a-form-model-item label="是否有采购订单" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isHaveOrder">-->
<!--              <a-input v-model="model.isHaveOrder" placeholder="请输入是否有采购订单" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
        </a-row>
      </a-form-model>
    </j-form-container>
      <!-- 子表单区域 -->
    <a-tabs v-model="activeKey" @change="handleChangeTabs">
      <a-tab-pane tab="库存明细" :key="refKeys[0]" :forceRender="true">
        <j-vxe-table
          keep-source
          :ref="refKeys[0]"
          :loading="bussInventoryDetailsTable.loading"
          :columns="bussInventoryDetailsTable.columns"
          :dataSource="bussInventoryDetailsTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="false"
          >
          <template v-slot:action="{row}">
            <a @click="historyRow(row)">历史查询</a>
          </template>
        </j-vxe-table>
      </a-tab-pane>
      <a-tab-pane tab="库存出入库明细" :key="refKeys[1]" :forceRender="true">
        <j-vxe-table
          keep-source
          :ref="refKeys[1]"
          :loading="bussInventoryInoutDetailsTable.loading"
          :columns="bussInventoryInoutDetailsTable.columns"
          :dataSource="bussInventoryInoutDetailsTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="false"
          />
      </a-tab-pane>
<!--      <a-tab-pane tab="库存关联采购订单" v-if="model.isHaveOrder === '1'" :key="refKeys[2]" :forceRender="true">-->
<!--        <j-vxe-table-->
<!--          keep-source-->
<!--          :ref="refKeys[2]"-->
<!--          :loading="bussInventoryPurchaseOrderTable.loading"-->
<!--          :columns="bussInventoryPurchaseOrderTable.columns"-->
<!--          :dataSource="bussInventoryPurchaseOrderTable.dataSource"-->
<!--          :maxHeight="300"-->
<!--          :disabled="formDisabled"-->
<!--          :rowNumber="true"-->
<!--          :rowSelection="true"-->
<!--          :toolbar="false"-->
<!--        />-->
<!--      </a-tab-pane>-->
    </a-tabs>
    <buss-in-out-detail-list-modal ref="selectInOutDetailList"
                          :modalWidth="modalWidth"
                          :code="code"
                          :quantity="quantity"
                          :category="category">
    </buss-in-out-detail-list-modal>
  </a-spin>
</template>

<script>

  import { getAction } from '@/api/manage'
  import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
  import { JVXETypes } from '@/components/jeecg/JVxeTable'
  import { getRefPromise,VALIDATE_FAILED} from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
  import { validateDuplicateValue } from '@/utils/util'
  import JFormContainer from '@/components/jeecg/JFormContainer'
  import BussInOutDetailListModal from "@comp/base/modal/BussInOutDetailListModal";

  export default {
    name: 'BussInventoryForm',
    mixins: [JVxeTableModelMixin],
    components: {
      JFormContainer,
      BussInOutDetailListModal
    },
    data() {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        modalWidth: 1300,
        category: '',
        code: '',
        quantity: '',
        model:{
          isHaveOrder: 0,
         },
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 1,
        validatorRules: {
        },
        refKeys: ['bussInventoryDetails', 'bussInventoryInoutDetails', 'bussInventoryPurchaseOrder',  ],
        tableKeys:['bussInventoryDetails', 'bussInventoryInoutDetails', 'bussInventoryPurchaseOrder',  ],
        activeKey: 'bussInventoryDetails',
        // 库存明细
        bussInventoryDetailsTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '单据编号',
              key: 'code',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '物料编号',
              key: 'materialCode',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '物料名称',
              key: 'materialName',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '规格型号',
              key: 'noneSpec',
              // type: JVXETypes.input,
              width:"120px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单位',
              key: 'meUnit',
              type: JVXETypes.select,
              width:"100px",
              dictCode: 'ji_unit',
              disabled: false
            },
            {
              title: '库存数量',
              key: 'quantity',
              // type: JVXETypes.input,
              width:"100px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            // {
            //   title:'入库数量',
            //   key: 'inventoryQuantity',
            //   width:"100px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            // {
            //   title:'出库数量',
            //   key: 'outboundQuantity',
            //   width:"100px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            {
              title: '占用数量',
              key: 'occupationQuantity',
              // type: JVXETypes.input,
              width:"100px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },

            // {
            //   title: '仓库编号',
            //   key: 'warehouseCode',
            //   // type: JVXETypes.input,
            //   width:"150px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            // {
            //   title: '仓库名称',
            //   key: 'warehouseName',
            //   // type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            {
              title: '库位编号',
              key: 'warehouseLocationCode',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '库位',
              key: 'warehouseLocation',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '批次号',
              key: 'batch',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '物料批号',
              key: 'materialBatchNumber',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '入库日期',
              key: 'inOutDate',
              // type: JVXETypes.date,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '生产日期',
              key: 'productionDate',
              // type: JVXETypes.date,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '状态',
              key: 'status',
              type: JVXETypes.select,
              width:"100px",
              dictCode: 'kc_status',
              disabled: false
            },
            {
              title: '质检状态',
              key: 'qualityInspectionStatus',
              type: JVXETypes.select,
              width:"100px",
              dictCode: 'zj_status',
              disabled: false
            },
            {
              title: '供应商编号',
              key: 'supplierCode',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '供应商名称',
              key: 'supplierName',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title:'宝洁供应商编码',
              align:"left",
              dataIndex: 'bjSupplierCode',
              width:120,
            },
            {
              title:'宝洁供应商',
              align:"left",
              dataIndex: 'bjSupplier',
              width:120,
            },
            {
              title:'宝洁单号',
              align:"left",
              dataIndex: 'bjOder',
              width:120,
            },
            {
              title: '辅助单位',
              key: 'auUnit',
              type: JVXETypes.select,
              width:"100px",
              dictCode: 'zl_unit',
              disabled: false
            },
            {
              title: '辅助数量',
              key: 'auxiliaryQuantity',
              // type: JVXETypes.input,
              width:"100px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '制单人',
              key: 'preparedBy',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '制单日期',
              key: 'preparedTime',
              // type: JVXETypes.date,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '操作',
              key: 'action',
              type: JVXETypes.slot,
              fixed: 'right',
              minWidth: '100px',
              align: 'center',
              slotName: 'action',
            }
          ]
        },
        // 库存出入库明细
        bussInventoryInoutDetailsTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '操作人',
              key: 'operator',
              // type: JVXETypes.input,
              width:"120px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '操作时间',
              key: 'operationTime',
              // type: JVXETypes.date,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '业务',
              key: 'business',
              type: JVXETypes.select,
              width:"120px",
              dictCode: 'kc_business',
              disabled: false
            },
            {
              title: '业务类型',
              key: 'businessType',
              type: JVXETypes.select,
              width:"120px",
              dictCode: 'kc_business_type',
              disabled: false
            },
            {
              title: '数量',
              key: 'quantity',
              // type: JVXETypes.input,
              width:"100px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            // {
            //   title: '单位',
            //   key: 'meUnit',
            //   type: JVXETypes.select,
            //   width:"100px",
            //   dictCode: 'ji_unit',
            //   disabled: false
            // },
            // {
            //   title: '库存ID',
            //   key: 'inventoryId',
            //    // type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            // {
            //   title: '库存明细ID',
            //   key: 'detailId',
            //    // type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            {
              title: '条码',
              key: 'barCode',
               // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            // {
            //   title: '业务ID',
            //   key: 'businessId',
            //    // type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            {
              title: '业务编号',
              key: 'businessCode',
               // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '备注',
              key: 'remark',
               // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            // {
            //   title: '备用字段一',
            //   key: 'spareOne',
            //    type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            // {
            //   title: '备用字段二',
            //   key: 'spareTwo',
            //    type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            // {
            //   title: '备用字段三',
            //   key: 'spareThree',
            //    type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            // {
            //   title: '备用字段四 ',
            //   key: 'spareFour',
            //    type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
            // {
            //   title: '备用字段五',
            //   key: 'spareFive',
            //    type: JVXETypes.input,
            //   width:"200px",
            //   placeholder: '请输入${title}',
            //   defaultValue:'',
            // },
          ]
        },
        // 库存关联采购订单
        bussInventoryPurchaseOrderTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '订单编号',
              key: 'orderCode',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '物料编号',
              key: 'materialCode',
              // type: JVXETypes.input,
              width:"150px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '物料名称',
              key: 'materialName',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '规格型号',
              key: 'noneSpec',
              // type: JVXETypes.input,
              width:"120px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单位',
              key: 'meUnit',
              type: JVXETypes.select,
              width:"100px",
              dictCode: 'ji_unit',
              disabled: false
            },
            {
              title: '订单数量',
              key: 'orderQuantity',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '入库中数量',
              key: 'inStorageQuantity',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '在途数量',
              key: 'inTransitQuantity',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '异常/退回数量',
              key: 'outlierQuantity',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '入库数量',
              key: 'inStockQuantity',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '制单人',
              key: 'preparedBy',
              // type: JVXETypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '制单日期',
              key: 'preparedTime',
              // type: JVXETypes.datetime,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        url: {
          add: "/inventory/bussInventory/add",
          edit: "/inventory/bussInventory/edit",
          queryById: "/inventory/bussInventory/queryById",
          bussInventoryDetails: {
            list: '/inventory/bussInventory/queryBussInventoryDetailsByMainId'
          },
          bussInventoryInoutDetails: {
            list: '/inventory/bussInventory/queryBussInventoryInoutDetailsByMainId'
          },
          bussInventoryPurchaseOrder: {
            list: '/inventory/bussInventory/queryBussInventoryPurchaseOrderByMainId'
          },
        }
      }
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
    },
    methods: {
      historyRow(row){
        this.category = row.id;
        this.code = row.code;
        this.quantity = String(row.quantity);
        this.$refs.selectInOutDetailList.add();
        this.$refs.selectInOutDetailList.title = "查看库存明细";
        this.$refs.selectInOutDetailList.disableSubmit = false;
      },
      addBefore(){
        this.bussInventoryDetailsTable.dataSource=[]
        this.bussInventoryInoutDetailsTable.dataSource=[]
        this.bussInventoryPurchaseOrderTable.dataSource=[]
      },
      getAllTable() {
        let values = this.tableKeys.map(key => getRefPromise(this, key))
        return Promise.all(values)
      },
      /** 调用完edit()方法之后会自动调用此方法 */
      editAfter() {
        this.$nextTick(() => {
        })

          let params = { warehouseId: this.model.warehouseId, materialId: this.model.materialId}
          this.requestSubTableData(this.url.bussInventoryDetails.list, params, this.bussInventoryDetailsTable)
          this.requestSubTableData(this.url.bussInventoryInoutDetails.list, params, this.bussInventoryInoutDetailsTable)
          this.requestSubTableData(this.url.bussInventoryPurchaseOrder.list, params, this.bussInventoryPurchaseOrderTable)

      },
      //校验所有一对一子表表单
        validateSubForm(allValues){
            return new Promise((resolve,reject)=>{
              Promise.all([
              ]).then(() => {
                resolve(allValues)
              }).catch(e => {
                if (e.error === VALIDATE_FAILED) {
                  // 如果有未通过表单验证的子表，就自动跳转到它所在的tab
                  this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
                } else {
                  console.error(e)
                }
              })
            })
        },
      /** 整理成formData */
      classifyIntoFormData(allValues) {
        let main = Object.assign(this.model, allValues.formValue)
        return {
          ...main, // 展开
          bussInventoryDetailsList: allValues.tablesValue[0].tableData,
          bussInventoryInoutDetailsList: allValues.tablesValue[1].tableData,
        }
      },
      validateError(msg){
        this.$message.error(msg)
      },

    }
  }
</script>

<style scoped>
</style>